
我自己  18:36:16
<template>
    <div :class='prefix'>
    <div :class="`${prefix}__top`">
    </div>
    <div :class="`${prefix}__content`">
      <el-card  :class="`${prefix}__form`">
        <div :class="`${prefix}__form__title`">用户登录</div>
        <el-form :model="loginInfo">
          <el-form-item label="用户名">
            <el-input v-model="loginInfo.username"/>
          </el-form-item>
          <el-form-item label="密码">
            <el-input v-model="loginInfo.password" type="password"/>
          </el-form-item>
          <el-form-item>
            <el-checkbox-group v-model="checkList">
              <el-checkbox label="1">记住密码</el-checkbox>
            </el-checkbox-group>
          </el-form-item>
          <el-form-item>
            <el-button
              @click="onSubmit"
              :class="`${prefix}__form__loginBtn`"
              type="primary">
              登录
            </el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
  </div>

</template>

<script>
import { login } from "@/api/api.js"
const prefix = 'login'
export default {
  name: prefix,
  data () {
    return {
      prefix,
      checkList: [],
      loginInfo: {
        username:"admin",
        password:"password"
      }
    }
  },
  created () {
    // this.$store.commit('changeNavActive', 5)
  },
  methods: {
    async onSubmit () {
      var data = await login(this.loginInfo);
      console.log(data)
      if(data.data.code == 200){
        
        console.log(data.data.data)
        sessionStorage.setItem("userInfo",JSON.stringify(data.data))
        if(data.data.data.is_superuser == true){
            this.$router.push("/index")
        }else if(data.data.data.is_admin == true){
             this.$router.push("/leadIndex")
        }else{
           this.$router.push("/user/project")
        }
        
      }else{
          this.$message.error(data.data.data);
      }

        // this.$router.push("/home")
    //   const data = {
    //     ...this.loginInfo,
    //     password: md5(this.loginInfo.password)
    //   }
    //   this.$router.push('/entry')
      // fetchLogin(data).then(
      //   res => {
      //     console.log(res)
      //     this.$router.push('/entry')
      //   },
      //   err => {
      //     console.log(err)
      //   }
      // )
    }
  }
}
</script>

<style lang="scss">
html, body {
    height: 100%;
    width: 100%;
}
.login {
  background-color: rgb(8, 163, 164);
  height: 100vh;
  &__top {
    padding: 30px 50px;
    box-sizing: border-box;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    height: 130px;
    img{
        height:60px;
    }
  }
  &__content {
    background-image: url(../assets/img_login.jpg);
    width: 1360px;
    height: 515px;
    margin: auto;
  }
  &__form {
    width: 385px;
    margin-left: 860px;
    .el-card__body {
      background-color: #fff;
      padding: 0 36px !important;
      box-sizing: border-box;
    }
    .el-form-item__label {
      color: #7B90A7;
    }
    &__title {
      color: #262626;
      font-size: 24px;
      font-weight: bold;
      margin-top: 42px;
      margin-bottom: 27px;
    }
    &__loginBtn {
      width: 100%;
      margin: 30px 0;
      padding: 15px 0;
    }
  }
}
</style>
